//package com.exsun.gateway.jt809.kafka;
//
//import com.exsun.gateway.jt809.data.PushData;
//import com.google.gson.reflect.TypeToken;
//import exsun.jt808.data.config.jt808.Jt808ReceiveMsgTopic;
//import exsun.jt808.data.config.jt809.Jt809MsgIdConfig;
//import exsun.jt808.data.jt809_data.BasicVehicleInfo;
//import exsun.jt808.data.jt809_data.SendBaseEntity;
//import exsun.jt808.data.jt809_data.alarm.main.UpWarnMsgInfoEX;
//import exsun.jt808.data.jt809_data.video.main.UpAlarmMediaList;
//import exsun.jt808.data.kafka_data.KafkaJT808Data;
//import exsun.jt808.data.upload_data.jsatl12.AlarmAttachmentInfo;
//import org.apache.kafka.clients.consumer.ConsumerRecord;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.kafka.annotation.KafkaListener;
//import org.springframework.kafka.support.Acknowledgment;
//
//import java.lang.reflect.Type;
//import java.util.ArrayList;
//import java.util.List;
//
//
//public class JT809KafkaWarnMsgInfoExHandle{
//
//    private Logger logger = LoggerFactory.getLogger(JT809KafkaWarnMsgInfoExHandle.class);
//
//    //订阅媒体数据
//    @KafkaListener(topics = Jt808ReceiveMsgTopic.alarmAttachmentInfo, containerFactory = "mediaFileListFactory")
//    public void batchMediaMsgConsumerListen(List<ConsumerRecord<?, ?>> records, Acknowledgment ack) {
//        try{
//            //多媒体数据上传
//            Type type = new TypeToken<KafkaJT808Data<AlarmAttachmentInfo>>(){}.getType();
//            List<PushData> pushs =  super.done(records, type, (obj)->{
//                List<PushData> temp = new ArrayList<>();
//                BasicVehicleInfo basicVehicleInfo = devInfoService.getBasicVehicleInfo(obj.dvo);
//                SendBaseEntity entity = getAlarmFileList(basicVehicleInfo, obj);
//                if(entity == null)return temp;
//                byte[] body = sendMgrHandler.jt809Encode.upAlarmMediaList((UpAlarmMediaList)entity, Jt809MsgIdConfig.UP_WARN_MSG_FILELIST_REQ);
//                PushData pushData = new PushData(Jt809MsgIdConfig.UP_WARN_MSG, body);
//                temp.add(pushData);
//                return temp;
//            });
//            //发送错误，则不提交偏移量
//            if(pushs == null)return;
//            if(pushs.size() != 0){
//                logger.info("上报资源列表上传：{}条", pushs.size());
//            }
//            ack.acknowledge();
//        }catch(Exception e){
//            logger.info(e.getMessage());
//        }
//    }
//}
